package Z.Dao;

import Z.Entity.userS;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class userSDao {
    //数据库连接
    public static Connection getConn() {
        Connection conn = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/hospital", "root", "123456");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }
    //显示查询数据信息
    public static boolean isLogin(userS a) {
        Boolean bool = false;
        try {
            Connection conn = userSDao.getConn();
            String sql = "select bh from userS where username ='" + a.getUsername() + "'and password ='" + a.getPassword() + "'";
            PreparedStatement ps = conn.prepareStatement(sql);
            ResultSet rs = ps.executeQuery();
            bool = rs.next();
            rs.close();
            ps.close();
            conn.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return bool;
    }
}
